<!--
 * @Descripttion: 系统计划任务配置
 * @version: 1.0
 * @Author: sakuya
 * @Date: 2021年7月7日09:28:32
 * @LastEditors:
 * @LastEditTime:
-->

<template>
	<el-container>
		<el-main style="padding: 0 20px">
			<scTable
				ref="table"
				:data="data"
				:apiObj="apiObj"
				:params="search"
				:autoStart="false"
				stripe
			>
				<el-table-column
					label="#"
					type="index"
					width="50"
				></el-table-column>
				<el-table-column label="执行结果" prop="success" width="100">
					<template #default="scope">
						<span
							v-if="scope.row.success == true"
							style="color: #67c23a"
							><el-icon><el-icon-success-filled /></el-icon
						></span>
						<span v-else style="color: #f56c6c"
							><el-icon><el-icon-circle-close-filled /></el-icon
						></span>
					</template>
				</el-table-column>
				<el-table-column
					label="开始时间"
					prop="beginDate"
					width="200"
				></el-table-column>
				<el-table-column
					label="结束时间"
					prop="endDate"
					width="200"
				></el-table-column>
				<el-table-column
					label="耗时"
					prop="elapsedMilliseconds"
					width="200"
				></el-table-column>

				<el-table-column
					label="执行日志"
					prop="logs"
					width="100"
					fixed="right"
				>
					<template #default="scope">
						<el-button
							size="small"
							@click="show(scope.row)"
							type="text"
							>日志</el-button
						>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>

	<el-drawer
		title="日志"
		v-model="logsVisible"
		:size="500"
		direction="rtl"
		destroy-on-close
	>
		<el-main style="padding: 0 20px 20px 20px">
			<pre
				style="
					font-size: 12px;
					color: #999;
					padding: 20px;
					background: #333;
					font-family: consolas;
					line-height: 1.5;
					overflow: auto;
				"
				>{{ demoLog }}</pre
			>
		</el-main>
	</el-drawer>
</template>

<script>
export default {
	data() {
		return {
			logsVisible: false,
			demoLog: ``,
			data: [],
			search: {
				taskId: null,
			},
			apiObj: this.$API.taskScheduler.logPage,
		};
	},
	mounted() {},
	methods: {
		getList() {},
		show(row) {
			this.logsVisible = true;
			this.demoLog = row.msg;
		},
		setData(taskId) {
			this.search.taskId = taskId;
			this.$refs.table.upData(this.search);
		},
	},
};
</script>

<style></style>
